//
//  AdressSelectTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/12.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "AdressSelectTableViewCell.h"

@interface AdressSelectTableViewCell ()
{
    GLGWImageView * pushImageView;
}
@property (nonatomic,strong)GLGWLabel * leftTitlabel;
@property (nonatomic,strong)UISwitch * right_switch;
@end

@implementation AdressSelectTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.leftTitlabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(12), kWidthProportion_In_iPhoneTriploid(100), kHeightProportion_In_iPhoneTriploid(20)) theFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self];
        //
        self.inputTextField = [[GLGWTextField alloc] initWithFrame:CGRectMake(kX_With_View(self.leftTitlabel, 10), 0, self.contentView.width - kX_With_View(self.leftTitlabel, 45), self.contentView.height) titlePlaceholder:@"请选择" theFont:SYSTEMFONT(14) theTitColor:kColor_Rule_Black inSuperView:self.contentView];
        self.inputTextField.userInteractionEnabled = NO;
//        self.inputTextField.backgroundColor = kRandomColor;
        self.inputTextField.textAlignment = NSTextAlignmentRight;
        //
        self.right_switch = [[UISwitch alloc] initWithFrame:CGRectMake(KScreenWidth - kWidthProportion_In_iPhoneTriploid(55), kHeightProportion_In_iPhoneTriploid(6), kWidthProportion_In_iPhoneTriploid(40), kHeightProportion_In_iPhoneTriploid(24))];
        self.right_switch.hidden = YES;
        [self addSubview:self.right_switch];
        self.right_switch.transform = CGAffineTransformMakeScale( 0.8, 0.8);//缩放
        [self.right_switch setBackgroundColor:[UIColor colorWithHexString:@"#F2F2F2"]];//E9EBF0
        [self.right_switch setOnTintColor:[UIColor colorWithHexString:@"#45DB5E"]];//
        [self.right_switch setThumbTintColor:[UIColor whiteColor]];
        self.right_switch.layer.cornerRadius = kHeightProportion_In_iPhoneTriploid(13);
        self.right_switch.layer.masksToBounds = YES;
        [self.right_switch addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
        [self addSubview:self.right_switch];
    }
    return self;
}

-(void)setLeftTitString:(NSString *)leftTitString{
    _leftTitString = leftTitString;
    CGFloat leftWidth = [GLGWLabel sizeWithTheText:_leftTitString theLabelHeight:kHeightProportion_In_iPhoneTriploid(20) theTextFont:SYSTEMFONT(14)].width+2;
    self.leftTitlabel.width = leftWidth;
    self.inputTextField.x = kX_With_View(self.leftTitlabel, 10);
    self.inputTextField.width = KScreenWidth - kX_With_View(self.leftTitlabel, 10) - kWidthProportion_In_iPhoneTriploid(35);
    self.leftTitlabel.text = _leftTitString;
}

-(void)setShowSwitch:(BOOL)showSwitch{
    _showSwitch = showSwitch;
    self.right_switch.hidden = !_showSwitch;
}

-(void)setSwitchSelect:(BOOL)switchSelect{
    _switchSelect = switchSelect;
    self.right_switch.selected = _switchSelect;
    [self.right_switch setOn:_switchSelect];
}

-(void)switchAction:(UISwitch *)sender{
    sender.selected = !sender.selected;
    if (self.Block_SwitchACtion) {
        self.Block_SwitchACtion(sender.selected);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setArr:(NSArray *)arr{
    _arr = arr;
    DLog(@"---------%@",_arr);
}

@end
